package com.xiaoshuidi.cloud.module.finance.enums.order;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

@Getter
@AllArgsConstructor
public enum BankTransferStatusEnum {
    WAITING("待付款"),
    SUCCESS("已付款"),
    CLOSED("已关闭"), // 未付款交易超时关闭，或支付完成后全额退款
    FAILURE("待确认");

    private final String name;

    /**
     * 判断是否支付成功
     *
     * @param status 状态
     * @return 是否支付成功
     */
    public static boolean isSuccess(String status) {
        return Objects.equals(status, SUCCESS.name());
    }
    public static boolean isSuccess(BankTransferStatusEnum status) {
        return SUCCESS == status;
    }

    public static String getDesc(String name) {
        for (BankTransferStatusEnum value : values()) {
            if (value.name().equals(name)) {
                return value.getName();
            }
        }
        return "";
    }
}
